﻿using UnityEngine;
using System.Collections;

public class Jump : MonoBehaviour {

	public Movement playerMovement;
    public string sceneName;
	public float speed;

	void Update () 
	{
		if (Input.GetKeyDown (KeyCode.W) || Input.GetKeyDown(KeyCode.UpArrow)) 
		{
			if (playerMovement.grounded)
			{
				rigidbody2D.AddForce(new Vector2(0, speed));
                rigidbody2D.gravityScale = 3f;
                GetComponent<Movement>().speed = 3;
                GetComponent<Animator>().SetBool("Grounded", false);
                GetComponent<AnimationController>().Glass.SetBool("Grounded", false);
			}
		}
	}
	void FixedUpdate()
	{
		
	}
    void ChangeScene()
    {
        StartCoroutine(changeScene());
    }

    IEnumerator changeScene()
    {
        yield return new WaitForSeconds(1);

        Application.LoadLevel(sceneName);
    }
}
